﻿layui.define(['form'], function () {
   var $ = layui.jquery;
   var form = layui.form;


   //自定义验证规则
   form.verify({
       account: [reg.account, '账号长度为4~20个字符，由字母数据以及@@_- 符号组成'],
       password: [reg.pwd, '密码必须6到20位，且不能出现空格'],
       verifyCode: [/^[A-Za-z0-9]{4}$/, "验证码输入错误"]
   });
   form.on('submit(submit)', function (data) {
        var returnurl = $("#returnurl").val();
        //if (returnurl == undefined || returnurl == null || returnurl == '') {
        //   returnurl = '';
       //}
       data.field.remember = data.field.remember === 'on' ? true : false;
       app.login({
           url: $("#loginurl").val(), data: data.field, returnurl: returnurl, logindone: function (result) {
               if (result.Succeeded == false) {
                   $("#imgVerifyCode").click();
               }
           }
       });
      return false;
    });

    $("#imgVerifyCode").click(function () {
        $(this).attr("src", $("#verurl").val()+"?=r" + Math.random());
    });
    $(".inputlogin").keypress(function (e) {
       if (e.which == 13) {
          $("#btnlogin").click();
        }
    });
})
